<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>自定义表单验证的错误信息</title>
</head>
<script>
function check(){
	var pass1 = document.getElementById('pass1');
	var pass2 = document.getElementById('pass2');
	if(pass1.value == pass2.value){
		pass2.setCustomValidity("两次密码不能一致！");
	}
}
</script>
<body>
<form onSubmit="return check()">
	<input type="text" id="pass1" /><br />
	<input type="text" id="pass2" />
	<input type="submit" />
</form>
</body>
</html>
